package com.dudy.simpleFactory;

/**
 * @author <a href="mailto:wb-zhaojunwei@alibaba-inc.com">wb-zhaojunwei</a>
 * @version 1.0
 * @Description
 * @Since 2016/5/26
 */
public class Printer implements Output {
    /*需要打印的内容*/
    private String[] data = new String[MAX_CACHE_LINE * 2];
    /*记录当前打印的字数*/
    private int dataNum = 0;
    public void out() {
        while (dataNum > 0) {
            System.out.println("开始打印"+data[0]);
            /*移动*/
            System.arraycopy(data,1,data,0,--dataNum);
        }
    }

    public void getData(String msg) {
        if (dataNum > MAX_CACHE_LINE * 2) {
            System.out.println("输出队列已满，添加失败");
        } else {
            data[dataNum++] = msg;
        }
    }
}
